﻿using System.Linq.Expressions;

namespace AiQiuQuan.Sport.Core
{
    /// <summary>
    /// 后台任务服务
    /// </summary>
    public interface IBackgroundJobService
    {
        /// <summary>
        /// hostservice 调用
        /// </summary>
        Task Execute(CancellationToken cancellationToken);

        /// <summary>
        /// add background job
        /// </summary>
        /// <typeparam name="IService">注入的服务</typeparam>
        /// <param name="expression">lamada表达式</param>
        /// <param name="lockKey">分布式锁key;空,不执行并发锁定;请根据实际情况传值</param>
        void Transfer<IService>(Expression<Func<IService, Task>> expression, string lockKey = null);

        /// <summary>
        /// add background job
        /// </summary>
        /// <param name="expression">lamada表达式</param>
        /// <param name="lockKey">分布式锁key;空,不执行并发锁定;请根据实际情况传值</param>
        void Transfer(Expression<Action> expression, string lockKey = null);
    }
}
